<template>
    <div>
        <van-nav-bar id="reset" title="患者详情" left-arrow @click-left="backHandle" fixed z-index="100" />

        <div class="pageCon fuPage">

            <div class="listBox">
                <div class="listTop">
                    <span>
                        患者信息
                    </span>
                </div>
                <div class="lineInfo">
                    <span>{{ info.userName }}</span>
                    <span>
                        <span v-if="info.parentId == 0">家长</span>
                        <span class="lineBox" v-if="info.parentId == 0 && info.isVip == 1"></span>
                        <span v-if="info.isVip == 1">会员</span>
                    </span>
                </div>
                <div class="lineInfo" v-if="info.isVip == 1">
                    <span class="c9">会员到期时间</span>
                    <span>{{ info.vipTime }}</span>
                </div>
                <div class="lineInfo">
                    <span class="c9">联系方式</span>
                    <span>{{ info.userTel }}</span>
                </div>
            </div>

            <div class="listBox" v-if="familyList.length != 0">
                <div class="listTop">
                    <span>
                        家庭成员
                    </span>
                </div>
                <div class="listMain">
                    <div class="itemBox" v-for="( item, index ) in  familyList " :key="index">
                        <div>
                            <span class="c24">
                                <span>{{ item.userName }}</span>
                                <span>{{ item.userSex }}</span>
                                <span>{{ item.userTel }}</span>
                            </span>
                            <!-- <span class="c3 c31">详情</span> -->
                        </div>
                    </div>

                </div>
            </div>
            <div class="listBox">
                <div class="listTop">
                    <span>
                        历史续费记录
                    </span>
                </div>
                <div class="listMain">
                    <template v-if="orderList.length != 0">
                        <!-- <div class="itemBox" v-for="( item, index ) in  orderList" :key="index">
                <div>
                    <span class="c9">{{ item.createTime }}</span>
                    <span class="c3">￥{{ item.orderTotal }}</span>
                </div>
            </div> -->

                        <div class="itemBox" v-for="( item, index ) in  orderList " :key="index">
                            <div class="line1">
                                <span><span>订单编号：</span> {{ item.orderNumber }} </span>
                                <span>金额：{{ item.orderTotal }}</span>

                            </div>
                            <div>
                                <span>购买{{ item.orderType == 1 ? '亲情就诊次数' : item.orderType == 2 ? '家庭套餐' : '加号次数'
                                    }}</span>
                                <span>{{ item.createTime }}</span>
                            </div>
                        </div>



                    </template>
                    <div class="emptyBox" v-else>
                        <img src="../../assets/tip_content.png">
                    </div>
                </div>
            </div>
            <div class="listBox">
                <div class="listTop">
                    <span>
                        历史申请记录
                    </span>
                </div>
                <div class="listMain">
                    <template v-if="applyList.length != 0">
                        <div class="itemBox" v-for="( item, index ) in  applyList " :key="index">
                            <div class="line1">
                                <span><span>申请编号：</span> {{ item.orderNumber }} </span>
                                <span v-if="item.orderStatus == 0" class="wColor">
                                    审核人审核中
                                </span>
                                <span v-if="item.orderStatus == 1" class="passColor">
                                    已审核
                                </span>
                                <span v-if="item.orderStatus == 2" class="resColor">
                                    医助已驳回
                                </span>
                                <span v-if="item.orderStatus == 3" class="wColor">
                                    医助审核中
                                </span>
                                <span v-if="item.orderStatus == 4" class="resColor">
                                    审核人已驳回
                                </span>
                            </div>
                            <div>
                                <span>{{ item.orderType == 1 ? '亲情就诊' : '加号' }}申请</span>
                                <span>{{ item.createTime }}</span>
                            </div>
                            <div v-if="item.visitTime != null">
                                <span>就诊时间</span>
                                <span>{{ item.visitTime }}</span>
                            </div>
                        </div>
                    </template>
                    <div class="emptyBox" v-else>
                        <img src="../../assets/tip_content.png">
                    </div>
                </div>
            </div>
        </div>



    </div>

</template>

<script>
import { getPatientInfo } from '../../network/aide'
export default {
    name: 'HomeR',
    data() {
        return {
            isLoading: false,

            userId: '',

            info: {},
            familyList: [],

            orderList: [],
            applyList: [],
        }
    },
    mounted() {

    },
    methods: {

        apply(obj) {
            this.$dialog.confirm({
                title: '提示',
                message: '是否对该申请进行核销',
                cancelButtonText: '取消',
                confirmButtonText: '确认'
            })
                .then(() => {
                    // on confirm
                    console.log(obj);
                })
                .catch(() => {
                    // on cancel
                });
        },

        toPage(url, obj) {

            if (url == '/applyHistory') {
                this.$router.push(url)
            } else {
                this.$router.push({
                    path: url,
                    query: {
                        userId: obj.userId || 6,
                    },
                });
            }
        },
        backHandle() {
            this.$router.back()
        },


        getOrderList() {
            getPatientInfo({
                userId: this.userId
            }).then(res => {
                if (res.flag) {
                    console.log(res.data);
                    this.isLoading = false
                    this.info = res.data.user
                    this.familyList = res.data.users.filter(item => {
                        return item.userId != this.info.userId
                    })
                    this.applyList = []
                    this.orderList = []

                    res.data.userOrders.forEach(item => {
                        if (item.payType == 0) {
                            this.applyList.push(item)
                        } else {
                            this.orderList.push(item)
                        }
                    })

                    console.log(this.applyList);
                    console.log(this.orderList);

                    // this.applyList = res.data.recharges

                    // this.applyList = res.data
                }
            })
        },


        pullHandle() {

            this.isLoading = true
            this.getOrderList()
        }



    },
    created() {
        this.userId = this.$router.history.current.query.userId
        this.getOrderList()
    },
    //计算属性
    computed: {

    },

    filters: {

    },
    watch: {
    }

}

</script>

<style lang='less' scoped>
.pageCon {
    padding: 112px 20px 0 !important;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: #EEF1F7;
    overflow-y: scroll;
    // overflow: hidden;
}


.listBox {
    margin-bottom: 16px;
    width: 100%;
    // height: 100%;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0px 2px 6px 0px rgba(51, 51, 51, 0.08);
    // overflow-y: scroll;
    overflow: hidden;
}


.listTop {
    position: sticky;
    top: 0px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 30px 34px 10px 44px;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: bold;
    font-size: 28px;
    color: #333333;
    background: #fff;
}

.listTop>div>span:nth-child(2) {
    margin-left: 30px;
    color: #999999;
}

.itemBox {
    box-sizing: border-box;
    padding: 44px 30px 44px 44px;
    width: 100%;
    border-bottom: 2px solid #f2f2f2;
}

.itemBox>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 28px;
    color: #333333;
    line-height: 38px;

}

.itemBox>div:not(:first-child) {
    margin-top: 12px;
}

.itemBox>div:not(:first-child)>span {
    font-size: 24px;
    color: #999999;
}

.line1>span>span:nth-child(1) {
    color: #333;
}

.line1>span>span {
    font-size: 24px;
    color: #999999;
}

// .line1>span:nth-child(2) {
//     display: flex;
//     align-items: center;
//     justify-content: center;
//     width: 136px;
//     height: 48px;
//     border-radius: 24px;
//     border: 1px solid rgba(27, 178, 106, .5);
//     font-family: Source Han Sans CN;
//     font-weight: bold;
//     font-size: 20px;
//     color: #1BB26A;
// }


#reset /deep/ .van-nav-bar__left .van-nav-bar__text,
#reset /deep/ .van-nav-bar__right .van-nav-bar__text,
#reset /deep/ .van-nav-bar__left .van-icon {
    color: #333 !important;
}


.emptyBox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.emptyBox>img {
    margin: 40px 0;
    width: 374px;
    height: 314px;
}

.c9 {
    color: #999;
    font-size: 24px;
}

.c24 {
    color: #333;
    font-size: 24px;
}

.c24>span {
    margin-right: 20px;

}

.c3 {
    font-weight: bold;
    font-size: 24px;
}

.c31 {
    font-weight: 400;
}

.lineInfo {
    box-sizing: border-box;
    padding: 22px 26px 22px 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 24px;
    color: #333;
}


.lineBox {
    margin: 0 20px;
    display: inline-block;
    content: '';
    width: 4px;
    height: 14px;
    background: #999;
    border-radius: 2px;
}


.resColor {
    color: #F56C6C !important;
}

.passColor {
    color: #67C23A !important;
}

.wColor {
    color: #E6A23C !important;
}
</style>